<%-- 
    Document   : index
    Created on : 26/06/2013, 12:50:38 PM
    Author     : SHAI
--%>
<jsp:useBean id="beanUsr" class="bean.Usuario" scope="session" />
<jsp:useBean id="gArticulo" class="bean.gestionArticulos" scope="session" />             
<jsp:useBean id="Articulo" class="bean.Articulo" scope="session" />   
<%
    String accion = request.getParameter("accion");
    int idArt = Integer.parseInt(request.getParameter("idArt"));
    if (accion.equals("guardar")) {
        if (idArt == -1) {
            gArticulo.setArticulo(beanUsr.getIdUsuario(),request.getParameter("titulo"),request.getParameter("contenido"));
            response.sendRedirect("index.jsp");
        } else {
            gArticulo.setRevision(idArt, beanUsr.getIdUsuario(), request.getParameter("contenido"));
            response.sendRedirect("leerArticulo.jsp?articulo=" + idArt);
        }
    } else {
        int punteo = Integer.parseInt(request.getParameter("punteo"));
        int idUsr = Integer.parseInt(request.getParameter("idUsr"));
        if (punteo == 15) {
            int idRev = Integer.parseInt(request.getParameter("idRev"));
            gArticulo.setDenuncia(idArt, idRev, idUsr);
        } else {
            gArticulo.setVoto(idArt, idUsr, punteo);
        }
        response.sendRedirect("leerArticulo.jsp?articulo=" + idArt);
    }
    
%>
